package nl.avans.osgi.ds.client.datagrid.internal;

import java.util.Collection;

import nl.avans.osgi.ds.client.datagrid.PersonDataGrid;
import nl.avans.osgi.ds.client.datamodel.DataModel;
import nl.avans.osgi.ds.persistence.person.model.Person;

public class PersonDataGridImpl implements PersonDataGrid {

    private DataModel personModel;
    
    @Override
    public void setData(Collection<Person> persons) {
        if (personModel == null) {
            System.out.println("PersonDataGrid: Data model was not set.");
            return;
        }
        System.out.println("===== Person data grid ==================================");
        for (Person person : persons) {
            personModel.setData(person);
        }
        System.out.println("=========================================================");
    }
    
    protected void setDataModel(DataModel dataModel) {
        this.personModel = dataModel;
    }
    
    protected void unsetDataModel(DataModel dataModel) {
        this.personModel = null;
    }

}
